﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Word = Microsoft.Office.Interop.Word;

namespace HelloWorld
{
    public partial class BlogsManager : Form
    {
        public BlogsManager()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            object start = 0;
            object end = 0;
            //插到开头
            //Word.Range rng = Globals.ThisAddIn.Application.ActiveDocument.Range( ref start, ref end);
            //rng.Text = this.textBox1.Text;
            
            //插入到光标
            //Microsoft.Office.Interop.Word.Range WordRange = Globals.ThisAddIn.Application.Selection.Range;
            //WordRange.Text = this.textBox1.Text;


            Object Nothing = System.Reflection.Missing.Value;
            Word.Application WordApp = new Word.ApplicationClass();
            Word.Document WordDoc = WordApp.Documents.Add(ref Nothing, ref Nothing, ref Nothing, ref Nothing);
            //this.Shapes.AddPicture();
            string FileName = "E:\\快盘备份\\备份\\寝室_桌面\\1.jpg";//图片所在路径
            object left = 10;
            object top = 10;
            object width = 200;
            object heigth = 200;
            object LinkToFile = false;
            object SaveWithDocument = true;
            //object Anchor = WordDoc.Application.Selection.Range;
            object Anchor = System.Reflection.Missing.Value;
            //WordDoc.Application.ActiveDocument.InlineShapes.AddPicture(FileName, ref LinkToFile, ref SaveWithDocument, ref Anchor);
            Globals.ThisAddIn.Application.ActiveDocument.Shapes.AddPicture(FileName, ref LinkToFile, ref SaveWithDocument, ref left, ref top, ref width, ref heigth, ref Anchor); 
            //Globals.ThisAddIn.Application.ActivePresentation.ApplyTemplate("D://test.ppt");
        }
    }
}
